package cn.jsj.user.manager;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 添加一位律师信息
 * @author LI
 *
 */
 public class AddLawyerInfo extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("添加一位律师信息");

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("参数为---->"+"  "+request.getParameter("aeducationallevel").trim())
;
		 //新建一个律师对象
		 cn.jsj.pojo.TblLawyer tl=new cn.jsj.pojo.TblLawyer();
		 //赋值
		 tl.setAnnSurRegInfo(request.getParameter("aannsurreginfo").trim());
		 tl.setBirthTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("abirthtime")));
		 tl.setBusinessNumber(request.getParameter("abusinessnumber").trim());
		 tl.setDeleteLabel(0);
		 tl.setEducationalLevel(request.getParameter("aeducationallevel").trim());
		 tl.setGraduateSchool(request.getParameter("agraduateschool").trim());
		 tl.setHonestArchives(request.getParameter("ahonestarchives").trim());
		 tl.setIdentityNumber(request.getParameter("aidentitynumber").trim());
		 tl.setLawyerEmail(request.getParameter("alawyeremail").trim());
		 tl.setLawyerName(request.getParameter("alawyername").trim());
		 tl.setLawyerPhone(request.getParameter("alawyerphone").trim());
		 tl.setLawyerPwd("111111");
		 tl.setLawyerSex(request.getParameter("sex").trim());
		 tl.setPoliticalStatus(request.getParameter("apoliticalstatus").trim());
		 tl.setPopedomLevel(3);
		 tl.setPositionName(Integer.parseInt(request.getParameter("lawyerposition").trim()));



		 //新增的属性
		 tl.setLawyerComeTime(cn.jsj.utils.TimeDispose.transferDate(request.getParameter("alcometime").trim()));
		 //获得律师离开时间
		 String leaveTime=request.getParameter("alleavetime").trim();
		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("律师离开所时间------->"+leaveTime);
		 if(!"undefined".equalsIgnoreCase(leaveTime)&&leaveTime.length()!=0){
			 System.out.println(leaveTime);
			 tl.setLawyerLeaveTime(cn.jsj.utils.TimeDispose.transferDate(leaveTime));
		 }
		 tl.setLawyerAchriveInfo(request.getParameter("alachriveinfo").trim());
		 tl.setAchriveAddr(request.getParameter("alachriveaddr").trim());
		 tl.setHouseholdAddr(request.getParameter("alhouseholdaddr").trim());
		 tl.setEligibleNumber(request.getParameter("aleligiblenumber").trim());

		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("调试信息！！");

		 //保存律师信息
		 cn.jsj.dao.TblLawyerDAO tld=new cn.jsj.dao.TblLawyerDAO();
		 int saveResult=tld.saveLawyerInfo(tl);
		 //调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("调试信息！！----->"+saveResult);
		 //输出流
		 java.io.PrintWriter out=response.getWriter();
		 if(saveResult==1){
			 out.println("{message:'添加成功！'}");
		 }else{
			 out.println("{message:'添加失败！'}");
		 }

		 out.flush();
		 out.close();
	}
}